<?php

namespace IDock\Insurance\DBIC\Response;

use IDock\Http\Response;
use IDock\Insurance\DBIC\Response\AllDBICResponse;
use IDock\Printer\NonCar\NonCarProductListPrinter;
use IDock\Printer\NonCar\NonCarProductPrinter;
use IDock\Printer\NonCar\NonCarSubCoveragePrinter;
use IDock\Printer\UnderwritingRecallPrinter;

class NonCarProductListResponse extends AllDBICResponse
{
    public function printerInit(): Response
    {
        $printer = new NonCarProductListPrinter();

        $list = [
            [
                'productCode' => '076311401',
                'productName' => '驾逸安乘基础版-5座',
                'planCode' => '076311401',
                'planName' => '驾逸安乘基础版-5座',
                'premium' => '150',
                'maxLimit' => '5',
                'coverageList' => [
                    [
                        'subCode' => '',
                        'subName' => '驾驶者意外伤害保险责任',
                        'amount' => '100000',
                        'premium' => '',
                    ],
                    [
                        'subCode' => '',
                        'subName' => '驾驶者意外医疗保险责任',
                        'amount' => '10000',
                        'premium' => '',
                    ],
                    [
                        'subCode' => '',
                        'subName' => '意外住院津贴',
                        'amount' => '9000',
                        'premium' => '',
                    ],
                    [
                        'subCode' => '',
                        'subName' => '搭乘者意外伤害保险责任',
                        'amount' => '400000',
                        'premium' => '',
                    ],
                    [
                        'subCode' => '',
                        'subName' => '搭乘者意外医疗保险责任',
                        'amount' => '40000',
                        'premium' => '',
                    ],
                    [
                        'subCode' => '',
                        'subName' => '意外住院津贴',
                        'amount' => '36000',
                        'premium' => '',
                    ],
                ],
            ],
            [
                'productCode' => '076304401',
                'productName' => '四川一体货车驾乘险（200元）方案',
                'planCode' => '076304401',
                'planName' => '四川一体货车驾乘险（200元）方案',
                'premium' => '200',
                'maxLimit' => '5',
                'coverageList' => [
                    [
                        'subCode' => '',
                        'subName' => '驾驶者意外伤害保险责任',
                        'amount' => '100000',
                        'premium' => '',
                    ],
                    [
                        'subCode' => '',
                        'subName' => '驾驶者意外医疗保险责任',
                        'amount' => '10000',
                        'premium' => '',
                    ],
                    [
                        'subCode' => '',
                        'subName' => '搭乘者意外伤害保险责任',
                        'amount' => '100000',
                        'premium' => '',
                    ],
                    [
                        'subCode' => '',
                        'subName' => '搭乘者意外医疗保险责任',
                        'amount' => '10000',
                        'premium' => '',
                    ],
                ],
            ],
            [
                'productCode' => '076302901',
                'productName' => '驾驶安心20元',
                'planCode' => '076302901',
                'planName' => '驾驶安心20元',
                'premium' => '20',
                'maxLimit' => '2',
                'coverageList' => [
                    [
                        'subCode' => '',
                        'subName' => '驾驶者意外伤害保险责任',
                        'amount' => '10000',
                        'premium' => '',
                    ],
                    [
                        'subCode' => '',
                        'subName' => '搭乘者意外伤害保险责任',
                        'amount' => '40000',
                        'premium' => '',
                    ],
                ],
            ],
            [
                'productCode' => '076306001',
                'productName' => '驾享无忧客车-5座',
                'planCode' => '076306001',
                'planName' => '驾享无忧客车-5座',
                'premium' => '20',
                'maxLimit' => '50',
                'coverageList' => [
                    [
                        'subCode' => '',
                        'subName' => '驾驶者意外伤害保险责任',
                        'amount' => '10000',
                        'premium' => '',
                    ],
                    [
                        'subCode' => '',
                        'subName' => '驾驶者意外医疗保险责任',
                        'amount' => '1000',
                        'premium' => '',
                    ],
                    [
                        'subCode' => '',
                        'subName' => '搭乘者意外伤害保险责任',
                        'amount' => '10000',
                        'premium' => '',
                    ],[
                        'subCode' => '',
                        'subName' => '搭乘者意外医疗保险责任',
                        'amount' => '1000',
                        'premium' => '',
                    ],
                ],
            ],
            [
                'productCode' => '076306003',
                'productName' => '驾享无忧客车-7座',
                'planCode' => '076306003',
                'planName' => '驾享无忧客车-7座',
                'premium' => '30',
                'maxLimit' => '50',
                'coverageList' => [
                    [
                        'subCode' => '',
                        'subName' => '驾驶者意外伤害保险责任',
                        'amount' => '10000',
                        'premium' => '',
                    ],
                    [
                        'subCode' => '',
                        'subName' => '驾驶者意外医疗保险责任',
                        'amount' => '1000',
                        'premium' => '',
                    ],
                    [
                        'subCode' => '',
                        'subName' => '搭乘者意外伤害保险责任',
                        'amount' => '10000',
                        'premium' => '',
                    ],[
                        'subCode' => '',
                        'subName' => '搭乘者意外医疗保险责任',
                        'amount' => '1000',
                        'premium' => '',
                    ],
                ],
            ],
            [
                'productCode' => '076306002',
                'productName' => '驾享无忧客车-6座',
                'planCode' => '076306002',
                'planName' => '驾享无忧客车-6座',
                'premium' => '25',
                'maxLimit' => '50',
                'coverageList' => [
                    [
                        'subCode' => '',
                        'subName' => '驾驶者意外伤害保险责任',
                        'amount' => '10000',
                        'premium' => '',
                    ],
                    [
                        'subCode' => '',
                        'subName' => '驾驶者意外医疗保险责任',
                        'amount' => '1000',
                        'premium' => '',
                    ],
                    [
                        'subCode' => '',
                        'subName' => '搭乘者意外伤害保险责任',
                        'amount' => '10000',
                        'premium' => '',
                    ],[
                        'subCode' => '',
                        'subName' => '搭乘者意外医疗保险责任',
                        'amount' => '1000',
                        'premium' => '',
                    ],
                ],
            ],
            [
                'productCode' => '076316401',
                'productName' => '5-7座驾驶员意外客车',
                'planCode' => '076306002',
                'planName' => '5-7座驾驶员意外客车',
                'premium' => '10',
                'maxLimit' => '50',
                'coverageList' => [
                    [
                        'subCode' => '',
                        'subName' => '驾驶者意外伤害保险责任',
                        'amount' => '10000',
                        'premium' => '',
                    ],
                ],
            ],
            [
                'productCode' => '076316402',
                'productName' => '5-7座驾驶员+乘客意外客车',
                'planCode' => '076316402',
                'planName' => '5-7座驾驶员+乘客意外客车',
                'premium' => '20',
                'maxLimit' => '50',
                'coverageList' => [
                    [
                        'subCode' => '',
                        'subName' => '驾驶者意外伤害保险责任',
                        'amount' => '10000',
                        'premium' => '',
                    ],
                    [
                        'subCode' => '',
                        'subName' => '搭乘者意外伤害保险责任',
                        'amount' => 40000,
                        'premium' => '',
                    ],
                ],
            ],
            [
                'productCode' => '076316403',
                'productName' => '5-7座驾驶员+乘客意外及意外医疗客车',
                'planCode' => '076316403',
                'planName' => '5-7座驾驶员+乘客意外及意外医疗客车',
                'premium' => '30',
                'maxLimit' => '50',
                'coverageList' => [
                    [
                        'subCode' => '',
                        'subName' => '驾驶者意外伤害保险责任',
                        'amount' => '10000',
                        'premium' => '',
                    ],
                    [
                        'subCode' => '',
                        'subName' => '驾驶者意外医疗保险责任',
                        'amount' => '1000',
                        'premium' => '',
                    ],
                    [
                        'subCode' => '',
                        'subName' => '搭乘者意外伤害保险责任',
                        'amount' => 40000,
                        'premium' => '',
                    ],
                    [
                        'subCode' => '',
                        'subName' => '搭乘者意外医疗保险责任',
                        'amount' => 4000,
                        'premium' => '',
                    ],
                ],
            ],
        ];

        foreach ($list as $item) {
            $amount = 0;
            $productPrinter = new NonCarProductPrinter();
            $productPrinter->productCode = $item['productCode'] ?? '';//产品编码
            $productPrinter->productName = $item['productName'] ?? '';//产品名称
            $productPrinter->productType = '驾意险';
            $productPrinter->productDesc = '';
            $productPrinter->planCode = $item['planCode'] ?? '';//方案代码
            $productPrinter->planName = $item['planName'] ?? '';//方案名称
            $productPrinter->maxQuantity = $item['maxLimit'];//最大购买份数
            foreach ($item['coverageList'] ?? [] as $sub) {
                $subCoverage = new NonCarSubCoveragePrinter();
                $subCoverage->subCode = $sub['subCode'] ?? '';
                $subCoverage->subName = $sub['subName'] ?? '';
                $subCoverage->amount = $sub['amount'] ?? '';
                $amount += $subCoverage->amount;
                $productPrinter->subCoverageAppend($subCoverage);
            }
            $productPrinter->premium = $item['premium'];
            $productPrinter->unitAmount = $amount;

            $printer->productListAppend($productPrinter);
        }


        $this->printer = $printer;
        return $this;
    }
}
